package day10;

import day7.Student;

import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author oldliu
 * @since 1.0
 */
public class ObjWriter {
    public static void main(String[] args) {
        try {
            ByteArrayOutputStream bout=new ByteArrayOutputStream();
            Student stu = new Student("小东兴", "hefei瑶海", 21);
            ObjectOutputStream oin = new ObjectOutputStream(bout);
            oin.writeObject(stu);
            oin.close();
            byte[] bytes = bout.toByteArray();
            bout.close();
            System.out.println("stu对象的字节码是：");

            for (byte b:bytes) {
                System.out.print(b+" ");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
